using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

using AutoBase.Shared;

namespace WebControl
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            EntitySpaces.Interfaces.esProviderFactory.Factory = new EntitySpaces.LoaderMT.esDataProviderFactory();
            //DatabaseFunctions.InitialiseConnection(SystemSetting.DSN);

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }

        void Application_BeginRequest(object sender, EventArgs e)
        {
            HttpContext context = HttpContext.Current;
            string path = context.Request.Path.ToLower();

            int lastExtension = path.LastIndexOf(".aspx");
            if (lastExtension == -1)
            {
                return;
            }
            int lastContent = path.LastIndexOf("/content/");
            if (lastContent == -1)
            {
                return;
            }
            int lastSlash = path.LastIndexOf('/');
            string key = path.Substring(lastSlash + 1, (lastExtension - lastSlash - 1));

            context.RewritePath("~/Default.aspx", false);
        }


    }
}